package com.pgy.backend.controller;

import com.pgy.backend.entity.Teacher;
import com.pgy.backend.mapper.GuidenceAbilityCompetitionMapper;
import com.pgy.backend.mapper.TeacherMapper;
import com.pgy.backend.service.impl.TeacherService;
import com.pgy.backend.vo.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/teacher")
@PreAuthorize("hasAnyAuthority('teacher','root','teacher')")
@Api(tags = "教师相关接口")
public class TeacherController {
    @Autowired
    private TeacherMapper teacherMapper;

    @Autowired
    private TeacherService teacherService;

    @Autowired
    private  GuidenceAbilityCompetitionMapper guidenceAbilityCompetitionMapper;

    @PostMapping("/update")
    @ApiOperation(value = "更新教师信息")
    public ResultData update(@RequestBody Teacher teacher){
        //新增和更新
        return ResultData.success(teacherMapper.myupdateById(teacher));
    }
    @GetMapping("/{id}")
    @ApiOperation(value = "获取教师相关信息")
    public ResultData get(@PathVariable Long id) {
        return ResultData.success(teacherMapper.getById(id));

    }


}
